package com.example.concurrency.chapter4;

import java.util.concurrent.atomic.LongAccumulator;
import java.util.concurrent.atomic.LongAdder;

public class LongAccumulatorTests {
    public static void main(String[] args) {
        LongAdder longAdder = new LongAdder();
        LongAccumulator longAccumulator = new LongAccumulator((x, y) -> {return x+y;}, 0);

        for (int i = 0; i < 10; i++){
            longAdder.add(i);
            longAccumulator.accumulate(i);
        }
        System.out.println(longAdder.sum());
        System.out.println(longAccumulator.get());
    }
}
